const EventDispatcher = require("./EventDispatcher")
class CommonPage extends EventDispatcher {
    constructor() {
        super()
        let ps = getCurrentPages()
        this.source = ps[ps.length - 1]
    }

    setData(obj) {
        this.source.setData(obj)
    }
    getData(key, defaultValue = "") {
        return this.source.data[key] || defaultValue
    }

    get data() {
        return this.source.data
    }

    addMethod(name, f) {
        this.source[name] = f
    }

    getObjFromPage(key, defaultValue = null) {
        return this.source[key] || defaultValue
    }

}


module.exports = CommonPage;